from tree_gui import Ui_Form
import sys
from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QMessageBox, QFileDialog
from PyQt5 import QtWidgets, QtCore, QtGui
import matplotlib
matplotlib.use('Qt5Agg')
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
import matplotlib.pyplot as plt
import BST

class Demo(QWidget, Ui_Form):
    def __init__(self):
        super(Demo, self).__init__()
        self.setupUi(self)
        self.figure = plt.figure()
        self.canvas = FigureCanvas(self.figure)
        self.layout_init()
        self.button_show.clicked.connect(self._plot)

    def layout_init(self):
        self.h1_layout = QtWidgets.QHBoxLayout()
        self.groupBox_5.setLayout(self.h1_layout)
        self.h1_layout.addWidget(self.canvas)

    def _plot(self):
        ax = self.figure.add_axes([0.1, 0.1, 0.8, 0.8])  # ax1 = fig.add_axes([left, bottom, width, height])
        ax.plot([1, 2, 3, 4, 5])
        self.canvas.draw()


if __name__=='__main__':
    app = QApplication(sys.argv)
    demo = Demo()
    demo.show()
    sys.exit(app.exec_())